// 导入模块
var express = require("express");
var Login = express.Router();
const mysql = require("mysql");

Login.get("/", function (req, res, next) {
  const account = req.query.user;
  const password = req.query.password;
  console.log(account);
  var connection = mysql.createConnection({
    host: "127.0.0.1", //主机地址（默认为：localhost）
    user: "root", //用户名
    password: "wang123123", //密码
    port: "13306",
    database: "feigeroom", //数据库名
  });

  connection.connect();
  connection.query(
    `SELECT * FROM room WHERE room.renovation = "简单装修"`,
    function (err, results) {
      if (err) return console.log("并未找到");

      console.log(results); //JSON.stringify(results)
      res.send(results);
    }
  );
  // res.end(JSON.stringify(response));
});

module.exports = Login;
